The placeOrderCancel method cancels open order.
var placeOrderCancel(openOrder);
openOrder
Valid Order object instance filled with information for an existing open order.
This method returns true if order was placed successfully, false otherwise.
In order to cancel existing order, validate that open order instance contains a valid orderId.
The following example demonstrates the use of placeOrderCancel method. The code attempts to cancel all open order limit orders that match current symbol.
function start()
{
//retrieve short positions for all symbols
var account = getAccount();
var placeOrderCancel = false;
//determine whether order cancel needs to be placed
..
..
..
//if orders need to be canceled, find limit orders matching current symbol, and cancel all of them
if(placeOrderCancel)
{
//get all open orders
var orders = account.getOrders();
//modify all limit orders
for(var i = 0; i < orders.length; i++)
{
var openOrder = orders[i];
//if limit order, and if symbols match, then cancel
if(openOrder.getOrderType() == ORDERTYPE_LIMIT && openOrder.getSymbol() == this.getSymbol())
{
//submit order cancel request
var rc = account.placeOrderCancel(openOrder);
}
}
}
}
start(), getAccount(), Order Class, getSymbol()
Copyright © 2006-2009 ActiveTick LLC